package edu.zut.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

//实现Filter接口，完成过滤器的定义，过滤url
@WebFilter(filterName = "filterDemo3", urlPatterns = "/*")
public class FilterDemo3 implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("filter3初始化");
    }

    /**
     *
     * @param request  请求
     * @param response  响应
     * @param chain 过滤器链
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("filter3编写你的过滤逻辑");
        //一定要注意，资源的放行
        chain.doFilter(request,response);
    }

    @Override
    public void destroy() {
        System.out.println("销毁当前filterDemo3");
    }
}
